<?php
/*
Primary Author: Derek Shue
Secondary: Sean Margison, Alex Arey
Documentation: Cheng Yi
Updated: 12/10/2011
Module Description: The Add User form is used by administrators to add new users.
*/
class Application_Form_AddUser extends Zend_Form
{
    public function init()
    {
	$auth = Zend_Auth::getInstance();
	$rank = $auth->getIdentity()->getUserRank();
    $this->setMethod('post');
		
		$this->addElement('hidden','ID',array(
	    'label' => '',
	    )
	);		
		
			
		$this->addElement('text','LOGINNAME',array(
	    'label' => 'Login Name:',
		'validators' => Array(array('StringLength', false, array(1, 60)), ),
		'required' => true,
	    )
	);			
		
		
		
	$this->addElement('password','PW',array(
	    'label' => 'Password:',
		'validators' => Array(array('StringLength', false, array(5, 15)), ),
	    )
	);
	
	if(isset($_POST['PW'])){
	$pwconfirm = $_POST['PW'];
		
			$this->addElement('password','PW2',array(
			'label' => 'Confirm Password:',
			'validators' => Array(new Zend_Validate_Identical($pwconfirm), array('StringLength', false, array(5, 15)), ),
			)
		);
	}
	else{
	
		$this->addElement('password','PW2',array(
			'label' => 'Confirm Password:',
			'validators' => Array(array('StringLength', false, array(5, 15)), ),
			)
		);
	
	}
	
	/*
	$options is used to determine the type of user created by this form. '1' => Registered User, but is not set here.
	*/
	$options = Array('0' => 'Normal User', '2' => 'Admin');
	
	if($rank>1){
		$elementtype = "radio";
		$elementtext = "Rank";
		
	}
	else{
		$elementtype = "hidden";
		$elementtext = "";
		}
	
	$this->addElement( "$elementtype",'RANK',array(
	    'label' => "$elementtext",
		'multiOptions' => $options

	    )
	);
	
	$this->addElement('radio','TYPE',array(
	    'label' => 'User Type:',
		'multiOptions'=>array(
		'student' => 'Student',
		'teacher' => 'Teacher',
		'organization' => 'Community Partner',
		)
		
	  )
	);
	
		$this->addElement('submit','submit',array(
	    'label' => 'Submit Request')
	);
	

	}


}

